package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null;unique;comment:'用户名称'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
}
type RealName struct {
	gorm.Model
	RealName string `gorm:"type:varchar(20);not null;comment:'真实姓名'"`
	IdCard   string `gorm:"type:varchar(18);not null;comment:'身份证号码'"`
	UserId   int    `gorm:"type:int(10);not null;comment:'用户Id'"`
}

func (u *User) Create() error {
	return DB.Create(&u).Error
}

func (u *User) GetUser(Username string) error {
	return DB.Where("username = ?", Username).Limit(1).Find(&u).Error
}

func (ur *RealName) Create() error {
	return DB.Create(&ur).Error
}
func (ur *RealName) CheckRealName(userId int, idCard string) error {
	return DB.Where("user_id = ? && id_card = ?", userId, idCard).Limit(1).Find(&ur).Error
}
